package com.winit.tag.web;

import com.winit.common.base.BaseController;
import com.winit.common.util.Constants;
import com.winit.tag.manager.TagGroupManager;
import com.winit.tag.manager.TagManager;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Map;

/**
 * Created by wangjian on 2017/9/28.
 */
@RestController
@Api(value = "tagGroup", tags = {"tagGroup"}, description = "tagGroup")
@RequestMapping(value = "/api/v1/tagGroup")
public class TagGroupController extends BaseController {

    private static Logger logger = LoggerFactory.getLogger(TagGroupController.class);

    @Autowired
    TagGroupManager tagGroupManager;

    @RequestMapping(value = "/get", method = RequestMethod.GET)
    @ResponseStatus(HttpStatus.OK)
    @ApiOperation(value = "获取tagGroup")
    public
    @ResponseBody
    Map getTagGroup(@ApiParam(value = "tag分组code", required = false) @RequestParam(value = "groupCode", required = false) String groupCode,
                    HttpServletRequest request, HttpServletResponse response) {
        logger.info("com.winit.tag.web.TagController.getTagGroup: groupCode=" + groupCode);
        Map map = getRtn(Constants.RTN_SUCCESS_CODE, "", tagGroupManager.getTagGroup(groupCode));
        logger.info("com.winit.tag.web.TagController.getTagGroup: groupCode=" + groupCode + ",map=" + map);
        return map;
    }

}
